package com.java.system.common.msg;


/**
 * @ClassName: ResultGenerator
 * @Description: Result 生成工具
 * @Version: v1.0.0
 * @Author: greatesky
 * @Date: 2019/9/7 11:27
 * Modification History:
 * Date             Author      Version     Description
 * -------------------------------------------------------------
 * 2019/9/7      greatesky      v1.0.0      创建
 */
public class ResultGenerator<T> {

    public static Result genSuccessResult() {
        return new Result()
                .setCode("200")
                .setMessage("成功")
                .setIsSuccess(true);
    }

    public static <T> Result genSuccessResult(T data) {
        return new Result()
                .setIsSuccess(true)
                .setCode("200")
                .setMessage("成功")
                .setData(data);
    }

    public static Result genSuccessResult(String code, String message) {
        return new Result()
                .setIsSuccess(true)
                .setCode(code)
                .setMessage(message);
    }

    public static <T> Result genSuccessResult(String code, String message, T data) {
        return new Result()
                .setIsSuccess(true)
                .setCode(code)
                .setMessage(message)
                .setData(data);
    }

    public static Result genFailResult() {
        return new Result()
                .setIsSuccess(false)
                .setCode("-1")
                .setMessage("失败");
    }


    public static Result genFailResult(String code, String message) {
        return new Result()
                .setIsSuccess(false)
                .setCode(code)
                .setMessage(message);
    }

    public static <T> Result genFailResult(String code, String retMSg, T data) {
        return new Result()
                .setIsSuccess(false)
                .setCode(code)
                .setMessage(retMSg)
                .setData(data);
    }

}
